package basic.thread.again;

import java.util.concurrent.locks.Lock;

/**使用自己的可重入锁
 * @author bingo
 * @create 2018-02-28 14:38
 **/
public class Squence4 {

    private int value = 1;

    Lock lock = new MyLock2();

    public int getValue(){
    lock.lock();
    value=value+1;
    System.out.println("getValue");
    b();
    lock.unlock();
    return  value;
    }

    public void b(){
        lock.lock();
        System.out.println("b");
        lock.unlock();
    }

    public static void main(String[] args) {

        Squence4 sequence4 = new Squence4();
        new Thread(new Runnable() {
            @Override
            public void run() {
                while (true){
                    System.out.println(Thread.currentThread()+" "+sequence4.getValue());
                }

            }
        }).start();





    }
}
